$import("com.joypard.platform.log.email.EmailLogDI");
$import("com.joypard.platform.log.email.EmailLogField");

/**
 * 定义日志视图
 */
K.defView("com.joypard.platform.log.email.EmailLogView", {
	/**
	 * 显示相关组件到页面
	 */
	render : function() {

		this.eamilSearchPanel = this.createeamilSearchPanel();// 邮件日志搜索面板
		this.eamilGridPanel = this.createeamilGridPanel(); // 邮件日志列表面板

		this.MP = new K.Ext.MainPanel({
			items : [ this.eamilSearchPanel, this.eamilGridPanel ]
		});
	},

	/**
	 * 创建邮件搜索日志面板
	 */
	createeamilSearchPanel : function() {
		var options = {
			region : "north",
			title : "条件查询",
			iconCls : "p-search",
			frame : true,
			bodyCssCls : "search-gb",
			contentEl : "emailLog-search"
		};

		var me = this;
		$("#emailLog-search").keypress(function(evt) {
			var tagName = evt.target.tagName;
			if (tagName == "INPUT" && evt.keyCode == Ext.EventObject.ENTER) {
				
			}
		});

		return new K.Ext.Panel(options);
	},

	/**
	 * 拓展行
	 */
	expander : new Ext.ux.grid.RowExpander({
		tpl : new Ext.Template('<p><b>业务日志:</b><br>hello</p><br>')
	}),

	/**
	 * 创建日志的列表面板
	 */
	createeamilGridPanel : function() {
		var errorImage = "<img src='" + $res_path_resources
				+ "/images/button/cancel.png" + "' title='失败' />";
		var successImage = "<img src='" + $res_path_resources
				+ "/images/button/submit.png" + "' title='成功' />";
		var me = this;
		var options = {
			title : "日志列表",
			iconCls : "p-grid",
			margins : "0 2 2 2",
			region : "center",
			//plugins : me.expander,
			store : EmailLogDI.createEmailLogStore(),
			tbar : [ {
				text : "查询",
				handler : function() {
				}
			} ],
			//me.expander, 
			columns : [{
				header : "senderCode",
				width : 100,
				dataIndex : "senderCode"
			}, {
				header : "发送人",
				width : 100,
				dataIndex : "senderName"
			}],
			bbar : {
				xtype : "pagination"
			},
			listeners : {
				afterrender : function() {
					this.getStore().load({
						// 回调函数展开所有行
						callback : function() {
							alert(1);
						}
					});
				}
			}
		}
		return new K.Ext.grid.GridPanel(options);
	}

});
